/*
 * Caller.h
 *
 *  Created on: Jul 7, 2009
 *      Author: lfor
 */

#ifndef CALLER_H_
#define CALLER_H_

#include "Packet.h"

#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

// Errors
#define CALLER_OK 				0
#define CALLER_ERROR 			-1
#define CALLER_CANNOT_CONNECT 	1
#define CALLER_SOCKET_ERROR  	2
#define CALLER_INVALID_PARAM  	3
#define CALLER_NOT_ENOUGH_BUFFER  4

#define DEFAULT_PORT 2222

class Caller
{
public:
	Caller();

	int Initialize(char * InetAddr, int PortNum);
	int Finalize();
	int Call(StatusType * Status, char * Name, char * Params, char * Returns, char * Errors, int DataLength, char * Data);
	int List(char * Buffer, int Length);
	int Close();

private:
	sockaddr_in CallyAddr;
    int CallySock;

    int Initialized;

};

#endif /* CALLER_H_ */
